﻿using System;
using System.Windows;
using System.Windows.Data;

namespace KadalaSpree.XCore.Converters
{
    public class BoolVisibilityConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var visible = System.Convert.ToBoolean(value); ;

            if (InvertVisibility)
            {
                visible = !visible;
            }
            return visible ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new InvalidOperationException();
        }

        public Boolean InvertVisibility { get; set; }

        #endregion
    }
}